Invert the negate parameter to comply with how the algorithms work and what the negare argument is supposed to do. Few other minor additions or adjustments.