Fix implicit divergence regression

With a sprinkling of additional cleanup.

Review by @adriaanm

/cc @szeiger