Added a few more ArrayIndexOutOfBoundsException checks.