Pulled some things out for DI and added a logger