fixing some issues in the EP code.
fixes some serious regressions in EP