enormous diff to use the same register API for attributes (and a few fixes)