Diff cleanup and refactoring

Change-Id: I97ee43639c5e9bdbd262b9f8133ed6abd3535829