Fixed error with leaking environments