Begin refactor. Separate into tasks, general cleanup