Fixed issues issues dealing with empty and non existant directories.