Refactor dicom reader code.