Move cleanupOrphaned function to the proper util file.