[PMs] Random refactoring

* PM controller refactoring. Make a few subs utilities functions.
* Fixes to existing subs.