Found the bug. Was adding 1 to the max data, but often the data was really small. Fixed