add some comments and fixes for lua port