Fix mismatches seconds vs. milliseconds operations.

A few places in the code were not consistently converting Ruby's Time to milliseconds.