Move some useful code outside v1

Change-Id: I5cdb4e0b57e00743cb1a4409a1fc8b519ae38ddb
Merge "Move some useful code outside v1"