Refactored transform function to be more general.
Added transform to /map.