Remove code repetition in module setup

Also, the quite explicit name _add_formats_to_module_namespace() should
now explain what's going on.
Hide all non-API names in module namespace

This is relevant for tools that do instrospection, e.g. for
auto-completion in IDEs.