Improvements, add cuda kernel for inversion.