Refactore connect functionality and buffer service