fixed the malloc and free memory access errors (pointers from device were needed on host)