more bounds-checking fixes