Fixed several pointer bugs.