Made some refactorings