Improved unnesting of Apply

Instead of using complicated rewrites that tried to remove Apply
in a single step, this rewriter uses many small rewrite steps that
each is very simple to implement and understand. Together
they unnest most plans with Apply in them