Singleton and factory design pattern