TLS + some other changes + fixes