Improve mapping for more functions.

I moved the module definition to its own file because I think it's more convenient.
Is there a difference between ``result`` and ``err`` here?