Refactor integration into master