First pass at conflict-driven cause learning.

It's not a good thing when an optimization makes your program about 200x
slower. I think I must have done it wrong. There are some useful
organisational changes in here as well, so I can't just roll it back.

...hence the commit