Improvements to glm function (WIP).