Improve external class support.

- Make name an optional parameter that default to the name of the class.
- Improve documentation and rename function.