bugfixes and added SSL support