Some fixes for AI