Small changes and refrac
Basic networking boilerplate

Pulled in from network-simple by Renzo Carbonara and Michael Snoyman.
The code will be rewritten shortly.