Minor Refactoring, added comments
Improved network termination to make it instantaneous