network: Add a lock around write channel

Now that we have multiple threads, we need to ensure packets go out
in cohesive chunks.
parse: Zero-out command argument if argument is optional

If a command does not have a corresponding argument, then set the
value to zero rather than re-using the previous value.