Fix duplicate messages bug