patch gmap refactor