Fixed bug in reduce stage 4, cleanup