Fixed bugs in tun reader/writer

This is a rough draft. Tech details sorted.
Now I just need to fix up the layers of abstration a bit...
especially for the tun reader/writer/device configuration.