Fixed the buggy AI.

Also formatted every class.