Cosmetics and documentation

This PR just fixes some typos and adds missing API documentation for new Lua code.