PID not fully functioning

The PID library has commands to set output limits both low and high for that kind of situation, it effectively clamps the output value between two values you set. You shouldn't try or have to do it in your code for every output command you process.