Implement pids

Still problems with chi.