cuda: modified context management