New network code

Needs merging