Minor changes and code refactoring