ECOM-248 re-factoring code. fixing quality issues.