Measure: add repeat bars and tidy up the code