Made some changes, but the results still aren't reasonable

TODO: test the input data against the old code, to make sure it's not
just bad input. I doubt it, though