Further code refactoring