Some checks to ensure there are no index out of range panics