Fix two pointer bugs