I've just cherrypicked these commits. Can fix if you wish.