fixes to cumsumg and maxg