Backport fix from trunk.
Merge branch 'joyent/feature/miscfix/trunk' into joyent/release/trunk