Improve lua interface
Put glue functions into lua table and clean code