add  f_reduce flag and associated code, and some minor cleanup of code