refactor, cleanup and add new options

Change-Id: Ibae68abeb293a8e39c8b8d2f87ed2fe66166808b