Moved a ton of environment parsing code to environment and fixed a couple bugs.  Still need to separate render code from environment code