Cherry-picked from !1338 (merged) on 2016-patches, including also !1355 (merged) and !1726 (merged)
2016-patches