Make Junction optimization less costly.

This refactor splits analysis and transform, decreasing the cost of
the common case when we just analyze and realise we're not looking
at a Junction.
Refactor visit_op in optimizer.

This not only makes it a good bit cleaner, but also reduces the cost.