Rewrote more of the Lua API with the new interface. Some final tweaks remain on the Lua interface.