Minor refactorings

Make the code more clear and consistent