Some cleanup in gen_ad.c

Change-Id: If11f938ddf738fe8c549285c9de9b27052b07251