Rewrote queries to use pan.
Final holdout of raw SQL