Cleaned a bit the code, removed also clean_last_received function as it is not needed anymore