Safer operations on packetbuf. Fix code formatting