corrected a logical typo
added error handling in xml parsing and tmp dir cleanup