Cleaning up pk code