clustering functions moved from NAG to NAGtypes and have been refined