Tidying head code