Hotfix for #2862

It is very messy but should work.