some refactorings and some fixing of code smells