A Better Semantics for XQuery with Side-Effects