Fix failing tests.
General tidy up.