Some code refactorings