Fixed foraging loop functions after CLoopFunction API changed