Extracting boundary calculation code, adding layerAudit()