Fixed some pointer bugs