Fixed issue #309
Style cleanups in environment and a tiny bugfix.