Some caching would be nice to improve performance, perhaps like [this](http://www.lua.org/pil/17.1.html)