Migrate common functions.

Signed-off-by: Kouhei Maeda <mkouhei@palmtb.net>