Remove big synchronized block in hiddenlayerproc and outputlayerproc. Make some (layer-level) method synchronized when the method accesses shared variables