added thread-safety to datetime calls