(XDK) More work on AI routines