Changed assignment operator to use copy-swap idiom.