Corrected js time calculation.
Code cleanup.