Added resiliancy to unexpected errors in scan loop and debug messages to
show program trying to exit before join.