Dif export rewritten from scratch to remove dependencies