Just made code of AI look a little bit better. Added some comments there.
Refactoring + small optimization.