Refactored code for organization.

Change-Id: I993979bedd4d6d3d69d86506255306a4e15dc477