Rejigger things to be more testable to facilitate #8.