Fix: crash due invalid packet

Might also be seen as a little code cleanup