Zend certified PHP/Magento developer

Layout update for multiple cms pages using custom handle

I want to make some adjustments to most of the custom created cms pages with some exceptions however.
To achieve this I added a block and removed another block from cms_page_view.xml
I want to revert this for all the exceptions, which are some of the default cms pages like imprint, no-route, cookie policy etc.
Because I do not want to keep multiple xml files with the same content I tried this approach: Cms page custom layout update file for multiple pages – Magento 2.3.4

This is my cms_custom_handle.xml in my theme’s Magento_Cms/layout

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="cms.header" remove="true" />
        <referenceBlock name="page.main.title" remove="false"/>
    </body>
</page>

As you can see I want to remove a block I added in cms_page_view and “un-remove” another one.

Unfortunately this is not working.
All CMS pages still apply the changes of cms_page_view and do not apply my custom handle updates.

Debugging the code I can see that the plugin is getting called and the condition for my cms block identifier resolves correctly and adds the custom handle to the layout updates of the result. I do not see the changes in the frontend unfortunately.

This is my di.xml

<type name="MagentoCmsHelperPage">
    <plugin sortOrder="1" name="noFinderPages" type="VendorModulePluginHelperPagePlugin"/>
</type>

and an extract of the Plugin

public function afterPrepareResultPage(MagentoCmsHelperPage $subject, $result)
{
    if ($result instanceof MagentoFrameworkViewResultPage) {
        if ($this->isHandleApplicable()) {
            $result->addHandle('cms_custom_handle');
        }
    }

    return $result;
}

Debugging the code I can see this in the $result->layout->_update->handles for the cms page with the identifier “impressum”

default
cms_page_view
cms_page_view_id_impressum
cms_custom_handle

Just for testing I created a cms_page_view_selectable with the same content for the impressum page and added it as custom layout update in the backend.
This works.
So I assume the .xml is not the problem and since the adding of the handle works as well, maybe there’s a problem with the order in which the layout updates are being applied?
Since my custom handle update basically reverts the cms_page_view.xml I guess it’s important that this is being applied last.