Split out internal library functions for ptrees into a new file, created more, and fixed try and delete