XXX: better-pw hacking. WIP, and untested. Might not even compile.