Fixed bugs in single player mode and AI