fix connection leak and add possibility to configure pool size and idle timeout