remove bashisms, lame redudent statements, replace echo with printf on everything, remove $ from within arith, quote some vars to prevent glob, random fixes