Fixes bug in nested repeat loops and rect function.