cudaMemcpy error in freeChain, added more specific error checking