Refactor messager handling into own function
Add function to replace a node in a graph