Added some super ugly bounds checking, to stop the 'awww hell no that
array index is out of bounds I is gonna crash on your ass' bug