improve usage accounting and error handling