Merge branch 'upgrade-and-refactor'