merge Beherith's source changes from http://code.google.com/p/mapconv/