Lua changes

Closes #879