Refactored and fixed Singleton class