Refactoring and clean-up, allowed for deletion of temporary directories