Made meanResMS more general.