delete nil or empty arrays. fixes issue of improperly
set dictionaries. added an explicit clear function