add terminate_after_count to count response; additional asserts; minor cleanups