Fixes to the configure script for PM.

Doesn't fully work yet, but it's better than before.