Some refactorings to improve readability