Re-arrange shared_node deriv computation