Network code refactoring
misc