Partially fix #7048 plus some minor fixes