refactor(lua): cleanup Lua API, improve performance

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
refactor(lua): cleanup Lua API, improve performance