Fix and refactor eliminating explicit vars (OMS-92)