Cleaned up environment code