Fixed bug in ema.