Mapping function, some clean up.