AD code cleanup