Use case classes instead of tuples when storing Ints in order to avoid boxing, close #967