Done some refactoring