fix problem with connection waits, throw exception when connection fails, add printing listener (for debugging purposes)