Fix problems with my code.

My test worked, but now I can't find out what I did.  This fixes
some logic and type errors.