Little bit of refractoring, and tidying up