cleanup - refactored to simplify cleaning directories.