Refactor script, add new options
am: ef3baf689b

Change-Id: I5fef30f5c9e3cfd7e6c04c09fabfe77ac4c31292