clean up vars, begin /nii detection