fix unreliable assertion
fix unattached message update and validation
clean code