Add some error checking to EM to make it not crash with 0 instances of a class