Fixed access out of bounds in heredity code