Glm maint #1734 rebased

identical to #1734 except rebased and resolved merge conflicts.