Started work on sync

Plus a few minor changes