Fix NPE and permission issue (bad package)