added env + cleanup functionality + graceful failure