Small cleanups to the way the pk is determined.