Move common code to a common ancestor