Lots of changes to support unit testing.