Added conditional to buildDictionary foreach loop

Fixes situations where morphType is null
Updated code style