fixed possible synchronization bugs