Restrucutred code, made names consistent, remade AI.