Work around bug with delegates in for loops