group attachment and liberties algorithms