Various fixes and improvements from We Broke The World

@privat you might want to double check the typo fix in `ai`.