Partial refactor to use IoC