Improve intermag.py