Moving reusing pieces of code
Merge pull request #780 from andrerod/compat

Moving reusing pieces of code