remove pid stuff into its own lib