Improve logging output here.
Fix sync loop when no history exists yet.

History returns a boolean when no history at all is found (
as would be the case on a new install). Need to cast $modseq to int
to avoid the activesync server thinking it's a loss of state or
change from timestamps to modseq.

Related to Bug: 12531