better debugging in em.py