bugfix and better ssl support