merge from upstream
fix various memory leaks
fixes for windows build
bugfix : getAttribute without a namespace