Some compatibility fixes for Lua 5.1 as well as some fixes to make MSVC not throw a tantrum.