Fixed bugs in extendCuda