Feature architecture improvements

Changes AI behavior.
Adds new classes and moves code from main function to them.