Add support for Directories and start refactoring to share code between widgets