Handle edge cases and fix dates