Implementation of the abstract factory pattern.