Closes #63
Closes #64
Mostly nternal reorg of code and tests