Added mutex based synchronization.