some .sm changes, and ai.py fixes.