Fix possible memory leak on sync calls