Refactor common methods into util library.
Add Lua to C++ function interface.