Cleaned up lua sample.
Fixed a couple issues in scripting code.