ann.py: Various improvements.