Added proper logging, fixed TCP packet sending and added a debug-mode