Clean up some nasty code.
Tidy up a bit.
Fix errors in changes analysis. Results still seem incorrect.