Revert aggressive refactoring and fix selectionIsWrappedByMatchingBrackets