Update LUA helper functions

Some error handling stuff.