Includes duplicate removal with a bug.