Change closure to a function object and update iteration Reviewed-by: mgerdin, ecaspole
Reviewed-by: brutisso, stefank, david