Implemented control_thread and flow control

Implemented control_thread and all the things linked to that
Implemented some acks in comunication functions
Minor changes
Bugfix