Adding debug logging for several edge cases