Fix scannedonly memory management