Commit lua52 changes
Converted from 5.1 to 5.2 with a few minor modifications.
Merging lua52 branch