Fixed connection leak
Added session listener
Minor cosmetic changes