I think this is the final rewrite of simplify.