some fixes from Mikelis, plus made shells default to temporary (override with --persistent)