Move more common code

Change-Id: I8696670ac30bc7d354c9b1695f588126b85e1626