Fix NPE in packet handler, cleanupň