Done some minor refactoring