Revert the computation of transform_sg and transform_mg, and fix typos in error message.