Make set_attributes a record string

This reduces code duplication.