factor out zero test
cleanup
piece-wise linear functions