Improve capsule importing for random C-API