improve performance of some mdn routines