Extract common functionalities to re-usable library.

Summary: