Port to D7 #529772 as well as all other updates that went into the D6 version in the meantime; adapt to core API changes.