Bug fixes & some docs

Note to myself: figure out how to use LuaDoc