Bug fixes with datetime