Added intelligent routing to nodes, cleaned up code and added notes