Full of debugging code, but seemingly working.

Remember before when I said all the math was right?  Well, you didn't
really believe that, did you?  Anyway, after correcting what seems like
every calculation, I think it might be right now.  The code is full of
debugging calculations and print statements right now, but I want to
get this committed as a reference point.  I'll remove all that stuff
for the next commit.