marginally improve output, plus several bug fixes