Further code refactorization