Fix #176: fix NullReferenceException