Fixed some bugs in the visualization of loops