Fixed some bugs in confusion matrix calculation