Solved concurrency problems. Now the network state is only saved when
there has been some update since the DB load. Added some constants and
cleaned some code.