Fix NPE when retrieving root dir; cleanup