more fixes, better ai logic