forward-port Philipp Gühring's changes (except for the cipher suite