Fixes #4315
I like this approach more, I'll rebase and if jenkins is happy we'll use this one :)
rebased onto 607c635d2b28c9b57fa0b00dcb2280483137a60b
Pull-Request has been merged by pingou
Fixes #4315