Fixed many errors due to global arrays, back in working order now.