some fixes in terms of map

Mainly, make a intermediate function to get the keys we want. 
Did you merge with master instead of the java_rewrite_engine branch? This is getting confusing.