Directory.rb refactoring