Fix some modulo problem in data generation