Fixed bug on filling of peakIdx and nopeakIdx array: now it happens after checking for bad curve flag.