Adding missing imports
Some NPE safety