Lua cleanups

* Made gdi04c easier. And there was much rejoicing.
* Lua API documentation fixes
* Moves a small number of functions to more appropriate places. I'd like to get this done before the release is out so that we wouldn't have to change a released API.

Depending on what's get merged first, either this PR or #6748, #6792, #6795 and #6796 will need to be adjusted accordingly.