Replaced global cudaDeviceSynchronize() with stream synchronization through events