refactored a lot. more to do but it's going well.