Refactor into separate lua files