refactored fetch_map. some encoding fixes.