Backport 50c2f40712bab91e4bad1b2aa14c8e9ac1d2dc0a (issue #52) for the v7-stable branch