Added protection and correct return value from ImportDirectories