Small performance improvements in TypeFactory and ServiceLocator