major refactoring and fixes subsequent to code walkthroughs. It compiles I ship.