various improvements, esp. uniquify