added ref counting to clean swift local cache