Added locking for sync, added logging to separate sync file