output cleanup, and for other purposes