Merge the refactor branch into master