Specialize branched loops

Continuation of PR #469 inside the main repo.
This comment is just barely double-take worthy... remove it?