A couple of bugfixes plus layed the groundwork for the Lua API. Will actually implement it soon.