Port the scala network code, as yet untested