Various fixes to sync Lua scripting with recent updates

This just syncs various fixes that were made to the source tree while the Lua branch was outstanding that should be included in the lua tree, mostly from the python example

PR #189 was supposed to merge into master, this is just a duplicate pull/merge