Modifications to read directory from root file: more general code now