Detector construction: fixed some bugs