WP: build fixes.
MT: added Xdamage to linking list.
MT: added validity check.
MT: fixed a typo.
MT: create and return the quark iff model is valid.
MT: properly release the model.