Wow this is a horrible mess. I've got some test code working well. Now I need to blow it away and start from scratch with tests. At least I know it works.