work on CRM. rearrange lua stuff for implementing global lua functions.