implemented distance function (autoselect distance_2d or distance_3d)
fixed issue with extensions when converting to xml
remove debug output