correcting a bug that was deadlocking when sending and receiving messages