Don't NPE when a type declaration if broken.
Fixes some other test cases.
Closes #218