Fixed bugs. Improved ai.