Fixes Issue #1581; caused by assumption that type is null.

Fixes Issue #1581