Fix #98 - Fixed memory leak issues with the new network code.
Based on AbrarSyed's fix.