add sync support, and fix a few bugs
trying the new relay and sync support out