issue #4437: add vertex z support, fix some bugs.