This loop was essentially broken, I've rewritten it and will push it after you'll finish reviewing.