Added duplicate vertex removal code.