added nil check in dicom value write
missed nil check in dicom cleanup