Bugfixes and improvements, especially to AO