final cleanup for PEM serialization