Merging into master changes made for #5729 #5839 #5841 #5842