Rewrite modules to lua 5.2 style
Fixed bugs
Merge branch 'modules'