Don't flatten repeat loops, close #1355