Changed template registration

Templates now self-registering. Factory now singleton.