Right. I admit I thought of it was a bit late and I wanted to have a first patch…

@timdream, do you want me to factorize the code?