Moving code from map.h to map.c