NPE check and println cleanup