Fixed message factory cleanup functionality.