nanmedian template bug causes slowdown; closes #91