Fixed bugs in map conversion