Tidying of patterns