Added some synchronization to prevent sending garbage results.