Fixed a few off-by-n errors.