NPE fix and cleanup