Rationalising some duplicated code.