Add more thread safety