various bug fixes to network layer