Fixed everything but the ArrayIndexOutOfBoundsException