Add collision detection using box2d.

Also lots of other fixes, refactorings, etc.  I should make more
frequent commits.