Refactor into modules