Clean up and add ssl support
Fix syntactical errors