IO Stream and Directory refactoring