Did some refactorings