Clean up and group code

Change-Id: I7bf587c158782f8be9c04b08e814cf9d661210c2