Moved PI rate calculations into new subroutines