Production env

Looks like a lot of changes, but is more copy-and-paste than anything else.  Basically, broke code out into managebly-sized functions and added a function to create the production environment.
Just copied and pasted from existing code, I have no idea why we were using the old one in the first place, but it should probably be changed