Improvements to next_time() method.

Not yet tested though.