Refactored environments. Small fixes