Many changes to implement netowrking. Not functional yet.