diff --git a/bob/learn/em/MAP_gmm_trainer.cpp b/bob/learn/em/MAP_gmm_trainer.cpp
index 7b22bc572fe499c3b45807287028854949ba78b2..437e277d2535cf1fe72385595043ad4e53b3a7cf 100644
--- a/bob/learn/em/MAP_gmm_trainer.cpp
+++ b/bob/learn/em/MAP_gmm_trainer.cpp
@@ -78,6 +78,9 @@ static int PyBobLearnEMMAPGMMTrainer_init_base_trainer(PyBobLearnEMMAPGMMTrainer
   PyObject* keyword_relevance_factor = Py_BuildValue("s", kwlist1[1]);
   PyObject* keyword_alpha            = Py_BuildValue("s", kwlist2[1]);
 
+  auto keyword_relevance_factor_ = make_safe(keyword_relevance_factor);
+  auto keyword_alpha_            = make_safe(keyword_alpha);  
+  
   //Here we have to select which keyword argument to read  
   if (kwargs && PyDict_Contains(kwargs, keyword_relevance_factor) && (PyArg_ParseTupleAndKeywords(args, kwargs, "O!dO!|O!O!d", kwlist1, 
                                                                       &PyBobLearnEMGMMMachine_Type, &gmm_machine,
diff --git a/bob/learn/em/ivector_machine.cpp b/bob/learn/em/ivector_machine.cpp
index 607a449dc4fd613b01e0d8497d7f7651a0a1807e..73d4d96745415d7e42a7a17708e7849a221896a5 100644
--- a/bob/learn/em/ivector_machine.cpp
+++ b/bob/learn/em/ivector_machine.cpp
@@ -302,7 +302,7 @@ PyObject* PyBobLearnEMIVectorMachine_getUBM(PyBobLearnEMIVectorMachineObject* se
     (PyBobLearnEMGMMMachineObject*)PyBobLearnEMGMMMachine_Type.tp_alloc(&PyBobLearnEMGMMMachine_Type, 0);
   retval->cxx = ubm_gmmMachine;
 
-  return Py_BuildValue("O",retval);
+  return Py_BuildValue("N",retval);
   BOB_CATCH_MEMBER("ubm could not be read", 0)
 }
 int PyBobLearnEMIVectorMachine_setUBM(PyBobLearnEMIVectorMachineObject* self, PyObject* value, void*){
diff --git a/bob/learn/em/kmeans_machine.cpp b/bob/learn/em/kmeans_machine.cpp
index 352ccde12217e4f806239973c6b3b09efc8e31a7..81492109b66b6d4f42aaf943601e8b49aa8ad3c2 100644
--- a/bob/learn/em/kmeans_machine.cpp
+++ b/bob/learn/em/kmeans_machine.cpp
@@ -535,7 +535,7 @@ static PyObject* PyBobLearnEMKMeansMachine_get_variances_and_weights_for_each_cl
   
   self->cxx->getVariancesAndWeightsForEachCluster(*PyBlitzArrayCxx_AsBlitz<double,2>(input),variances,weights);
 
-  return Py_BuildValue("(O,O)",PyBlitzArrayCxx_AsConstNumpy(variances), PyBlitzArrayCxx_AsConstNumpy(weights));
+  return Py_BuildValue("(N,N)",PyBlitzArrayCxx_AsConstNumpy(variances), PyBlitzArrayCxx_AsConstNumpy(weights));
 
   BOB_CATCH_MEMBER("cannot compute the variances and weights for each cluster", 0)
 }