Connection lifetime improvements. Template fixes