Some major refactoring and fixing.  Still need more.