Added thread safety to initialize()