Rework ::attrs and ::encode logic.