Factored out common code in Problem class