reshuffling some initialisation code so it's slightly more natural