Simplified the API by taking care of cuda memory management in kernel functions.