AI tweaks and changed layout code