Isn't this initialization code already somewhere? Could it be reused / moved into a common function, so that there's only one copy of this code?