Fix issues when using CUDA: use Kokkos::min/max instead of std::min/maxand replace one KOKKOS_LAMBDA with KOKKOS_CLASS_LAMBDA