Minor bug fixes plus API and event additions

Minor bug fixes, Lua API additions and a couple of events