Fix bug in cleanup where it was using legacy fields