Merging major refactor effort back to master