Use factory function to support multiple instances per process. Fixes #11.