final cleanup for PEM serialization

final cleanup originally started by #1564 
This doesn't look right?