Lua 5.2 & misc fixes

Fixes build with lua 5.2 and also updates some deprecated autofoo stuff