Fixed lots of endgame bugs and AI decision bugs. Added some polish.