bugfixes to mesh distance