added ssl support, moved initiation into main function