How did foreign influences both help and hurt Korea?