Refactor to make testing a bit easier.