reorganization; changed WaitForMessage and added StartListening