Fixes to address issues raised in comments to PR.

Prune empty fields `plugin_instance` and `type_instance` only, instead of crawling through entire hash looking for empty values.
Simplified iterating through values
Fix empty string vs. nil check.