Converted some anonymous inner classes to lambdas.
CachingFactory: removed.
SingletonFactory: removed.