Fixed a bunch of bugs with syncing

These bugs where introduced in #8 and #9. Hopefully all fixed now.
Merge pull request #15 from cmcnamara87/bug-fixes-for-sync

Fixed a bunch of bugs with syncing