Fix some bugs in network

As well as merge everything into reset thread.