some refactoring, figuring out why mkdir() wont call debug()