Minor internal updates for future compatibility.

The LuaJIT branch has several minor changes such as more metamethod overrides and a portable definition of `table.pack`. Landing these on master separately.