refactored PTR stuff a bit