Fixed a few bugs in the training of real detectors