Fix loops in closures