simplify DMI bulk code
fix sqr->pow2 (Thanks Mykola)