Fixed some bugs in the anomaly detection