Check for changes before assigning to instance

Added checks for inequality before assigning modified values back to the
instance object.
This is to prevent undefined being assigned to a property where
previously it did not exist.  This is causing issues when validating
objects that are passed to MongoDB because undefined is coerced to null
by the node driver.