Currently the active attribute is stored as an index. This should be changed to a string, but until then, adding or removing an attribute changes the indeices. The workaround is to store the name and fix the active attribute after the change.