Fix moment generation code to run under np1.6