Fix bug where inner parentheses could be incorrectly matched