Refectored environment loading