This is a very slow and ugly way of fixing #2295
Hopefully someone if not me can do better in future.