Added code to enable generation of multilayers and statistics collection on a layerwise basis