Mior changes and refactoring