Merge refactor into master