Fixed two crashes cause by not checking bounds