applied patches 7-8 from http://www.lua.org/bugs.html