refactor ai into multiple classes, general clean-up