Check types in RegisterWriter. Fix exception in RegisteredMessage