Larz/matching brackets

This is for #5347.