Initialize all members

Found by coverity.
Don't dereference iterator after invalidating it

Found by coverity.