cleanup
moved env saving back to bash; minor fixes
cleanup
even more cleanup
reordering and minor touches