Improved javascript. Added failure handling for timestamps.