Ability to specify endpoint mappings.

Also fix a bug with safe id.