Refactorded environment loader