cleanup directory code