Major rework and cleanup to make lua and lanes work better