moved network code away into it's own file.