end of part 1 of major refactor