Matching braces and removing extra stuff