Improved numerical robustness.

A few more tests should be done, but this should be the last update to
the core implementation. If expectation is met, the only pending task
before the first release should be the protocol review.