ugly fix with linking problem
cleaned up lua code