Fixes relating to databases covering large timespans.

Two commits, as discussed here: https://github.com/oetiker/rrdtool-1.x/issues/368