Fixed wrong error messages caused by copy-paste
Fixed mislabeled error messages
Added piecewise function macro