[#1598] factor out common startup code