Fixed bugs in peak finding