Very minor changes for Sonar... simplified a boolean expression in
ResolveURI and ensured some resources where closed by adding in
"finally" blocks.