Locality and the algebraic structure of quantum mechanics