Fixing a few bugs
Merge branch 'reduce_env'