MOSYNC-3066

...e instead of crashing.

Also fixed some warnings.