Although maybe this is overboard :)

It'd be nice to reuse the lower-level unify functions though.