Factor out repeated actions for object creation.