Rearranging some stuff in g_ai.c