Free element name after read
Add missing return and break statements
Fix typos in comments and log messages