Refactoring of some functions in pico_socket_multicast.c to decrease complexity