Another pass at testing and tidy up.