Updated code to Lua 5.2, very difficult process.