improved ai, some fixes