cleanup and some debug output of certificates