Properly waits for and reads messages