added code for reading main config and restructured tls init code