master1 idea
(cherry-picked from 7d0a66b)

master2 idea
(cherry-picked from cfb1c73)