Move env-based tasks into their own rake file
Refactor to smaller methods
Refactor for code clarity