Refactor into multiple files, wrap main in an app class