added SSL support. more cleanup.