Fixes #973.

Adds a NPE guard.
Fixes #975.

Adds a NPE guard for the builtin package. However the builtin package SHOULD always be available (from the SDK) so this means that the there is no SDK configured..
Another NPE guard.
fix #865