syncdata: implement protocol.

Done somewhat hacky, but it's much simpler this way. Probably in
the future, there will be some good refactoring needed.