Use a helper function for getting current time in seconds.
Fix some jshint warnings.
Fix typo in comment