minor code cleanup
fix crash when trying to validate comments or PIs instead of elements
changelog
merge 3.2 branch into master