Small changes and refactoring