Fix issue with datetime handling