node: refactoring of message handling