Fix the pointer bugs