Massive refactoring

Restructured most of the network implementation to ease scripting of
empirical tests.