Fixes matching begin and end identifiers