Fix inversion between package and module
Fix potential NPE when Module.getUnit() returns null