Improved synchronization logic.