Fixed minor issues in detection of secondaries