Some reorganisation; beginning of framework for network code