[IMP] Improved code to remove issues with js new Date() function and misc changes