Added environment class and small fixes