Review fixes

Add doxygen-style comments.
Make sure it compiles with DISABLE_SSL.
Move variables declaration to the top of method to make sure it compiles
on MSVC.
Remove unused variables.