fixed a bug in em.py, minor changes