Refactoring and clean-up

Change-Id: I0b81d2838efd07c0305731ee320d9e20fe3887a8