minor improvements on exit