TMDM-7702: bug fix on EE and code clean-ups (Still one more known subtle bug on EE)