more refactoring and cleanup in ReduceHandler. no functionality changes