Remove duplicated code in constructors.