Merge refactoring into master