Added na_cmp option to lmatch and cleanup of code