Fix (hopefully) most of the R/W errors inside the new Lua API