Fix message duplication bug. This closes issue #28.