The brake switch inputs are susceptible to noise. They should be in shielded cable with the shield grounded on 1 end. You can also wire a resistor from the inputs to P24 to keep them honest. What kind of machines are you working with?