Minor changes and refactoring