Fix for #877: modules with no package declarations cause NPEs