Splited the functionalities into functions, so the main file stays clean. Added workers to handle the connections and buffer list. TODO: thread safe operations and testing