Bug fixes in SSL implementation