Reimplement lib to be able to work with several connections