Which territory was an independent republic before being added to the United States?