fixes initialisation of global openssl structures. 

introduce new public function "mg_cleanup()".

fixes issue #39