finished first pass at full refactor