Adding semaphore lock to JSON saver