Some refactorings to increase readability. Minor changes