scrobbler2: refactored the main loop of the communication thread.