Fixed handling directories while loading files.