Modified KL, JSD code