Refactored peregrine partially.