Done some refactoring work