Improving cuda backend