Some fixes/cleanup, some progress towards fixing sync.