Fixed some compiler warnings.
Bug: clearing attributes should only reset their value and tx rather than deleting them entirely

Fixes #3604
Fixed some more compiler warnings (when using -Wall).