Improve performance of pivotMap and combineMaps