Fix leaks in XMLimport.
Merge branch 'release_31' into development

Fix leaks in XMLimport.
Remove unnecessary casts.
Merge pull request #195 from ahmedcharles/casts

Remove unnecessary casts.
Dead code removal.