A bit more cleanup, making it a bit more testable