Fixed an off-by-one problem with the error counting.