Fixed an error with printing: was accessing arrays out of bounds.