Further refactoring and separation