Cleanup
Fixes issues with AddAttribute in several places
Avoid KeyNotFoundException