port to lua 5.2

Lua 5.2 introduced some API changes. This ports the source to lua 5.2