keep track of last command's exit value, a few other minor changes