Fix some quality flaws
Fix NPE