I'd really like to see the inside of this loop as a sub-method, or at least some parts of it. It's getting pretty intense up in here and that would really help make this more clear.