added more checks and fixed small sync bug

Ignore-this: 97d3f0422ef83018d55546f655cffa50

darcs-hash:20131215051429-c21fe-99bace734f9eaaba9074a3cc586fee2aa58ddeed