Ideally I want to remove this entire file!

It has so many problems with it just 'cause of how Lua works. But lets at least make the `types` function less buggy and much more efficient!