Text this: Guarded Second-Order Logic, Spanning Trees, and Network Flows