Fix OOIION-1171: Moved directory cleanup into directory and also apply to lookup