The invention relates to a milking device, a method and software. The milking device includes a device for preventing contaminants in milk during the milking of an animal. The milking device includes a teat cup to be attached to a teat and to be connected to a milk collecting vessel for collecting the milk. The device further includes a detector for generating and transmitting a disruption signal as a result of the detection of a premature becoming detached of the teat cup, and/or as a result of the detection of the incorrect attachment of a teat cup. The device also includes a management system to separate, on the basis of the disruption signal, the milk from the animal into a first amount of milk, which is led to a first destination, and a second amount of milk, which is led to a second destination different from the first destination.