Refactoring to remove singletons