Added remove listener template + making sure to close connection on destructor