Some work on the decision making of the AI

And some more code cleanup