Update network implementation

The tutorial the old implementation was based on has a potential memory
leak.

--UNTESTED--