protected virtual void ReceiveCallback(IAsyncResult AR)
        {
            try
            {
                Socket Sock = (Socket)AR.AsyncState;
                int NumBytesRead = Sock.EndReceive(AR);

                /** Cant do anything with this! **/
                if (NumBytesRead == 0) { return; }

                byte[] TmpBuf = new byte[NumBytesRead];
                Buffer.BlockCopy(m_RecvBuf, 0, TmpBuf, 0, NumBytesRead);
                m_RecvBuf = new byte[11024]; //Clear, to make sure this buffer is always fresh.

                if (m_TempPacket == null) //No temporary data was stored - beginning of new packet!
                {
                    //The packet is given an ID of 0x00 because its ID is currently unknown.
                    PacketStream UnknownPacket = new PacketStream(0x00, (ushort)NumBytesRead, TmpBuf);
                    byte ID = UnknownPacket.PeekByte(0);
                    Logger.Log("Received packet: " + ID, LogLevel.info);

                    ushort PacketLength = 0;
                    m_Handler = FindPacketHandler(ID);
                    PacketLength = m_Handler.Length;

                    if (PacketLength == 0) //Variable length!
                    {
                        if (NumBytesRead >= (int)PacketHeaders.ENCRYPTED)
                            PacketLength = UnknownPacket.PeekUShort(1);
                    }
                    else
                    {
                        if (m_TempPacket == null)
                            m_TempPacket = new PacketStream(ID, PacketLength);

                        byte[] TmpBuffer = new byte[NumBytesRead];

                        //Store the number of bytes that were read in the temporary buffer.
                        Logger.Log("Got data, but not a full header - stored " +
                            NumBytesRead.ToString() + "bytes!\r\n\r\n", LogLevel.info);
                        Buffer.BlockCopy(m_RecvBuf, 0, TmpBuffer, 0, NumBytesRead);
                        m_TempPacket.WriteBytes(TmpBuffer);

                        TmpBuffer = null;
                    }

                    if (PacketLength != 0)
                    {
                        if (NumBytesRead == PacketLength)
                        {
                            Logger.Log("Got packet - exact length!\r\n\r\n", LogLevel.info);

                            OnPacket(new ProcessedPacket(ID, m_Handler.Encrypted, m_Handler.VariableLength, PacketLength,
                                m_ClientEncryptor, UnknownPacket.ToArray()), m_Handler);
                        }
                        else if (NumBytesRead < PacketLength)
                        {
                            if (m_TempPacket == null)
                                m_TempPacket = new PacketStream(ID, PacketLength);

                            byte[] TmpBuffer = new byte[NumBytesRead];

                            //Store the number of bytes that were read in the temporary buffer.
                            Logger.Log("Got data, but not a full packet - stored " +
                                NumBytesRead.ToString() + "bytes!\r\n\r\n", LogLevel.info);
                            Buffer.BlockCopy(m_RecvBuf, 0, TmpBuffer, 0, NumBytesRead);
                            m_TempPacket.WriteBytes(TmpBuffer);

                            TmpBuffer = null;
                        }
                        else if (NumBytesRead > PacketLength)
                        {
                            Logger.Log("Received more bytes than needed for packet. Excess: " +
                                (NumBytesRead - PacketLength) + "\r\n", LogLevel.info);
                            PacketHandler OldHandler = m_Handler;

                            byte[] PacketBuffer = new byte[PacketLength];
                            Buffer.BlockCopy(UnknownPacket.ToArray(), 0, PacketBuffer, 0, PacketBuffer.Length);

                            OnPacket(new ProcessedPacket(ID, OldHandler.Encrypted, OldHandler.VariableLength,
                                OldHandler.Length, m_ClientEncryptor, PacketBuffer), OldHandler);

                            byte[] TmpBuffer = new byte[NumBytesRead - PacketLength];
                            Buffer.BlockCopy(UnknownPacket.ToArray(), (NumBytesRead - PacketLength) - 1,
                                TmpBuffer, 0, TmpBuffer.Length);

                            m_TempPacket = new PacketStream(TmpBuffer[0], (ushort)(NumBytesRead - PacketLength),
                                TmpBuffer);
                            m_TempPacket.WriteBytes(TmpBuffer);

                            m_Handler = FindPacketHandler(ID);
                            PacketLength = m_Handler.Length;

                            if (PacketLength == 0) //Variable length!
                            {
                                if (m_TempPacket.BufferLength >= (int)PacketHeaders.ENCRYPTED)
                                {
                                    PacketLength = UnknownPacket.PeekUShort(1);
                                    m_TempPacket.SetLength(PacketLength);
                                }
                            }

                            TmpBuffer = null;
                        }
                    }
                }
                else
                {
                    m_TempPacket.WriteBytes(TmpBuf);

                    if (m_TempPacket.Length == 0) //Variable length!
                    {
                        if (NumBytesRead >= (int)PacketHeaders.ENCRYPTED)
                            m_TempPacket.SetLength(m_TempPacket.PeekUShort(1));
                        else
                        {
                            byte[] TmpBuffer = new byte[NumBytesRead];

                            //Store the number of bytes that were read in the temporary buffer.
                            Logger.Log("Got data, but not a full header - stored " +
                                NumBytesRead.ToString() + "bytes!\r\n\r\n", LogLevel.info);
                            Buffer.BlockCopy(m_RecvBuf, 0, TmpBuffer, 0, NumBytesRead);
                            m_TempPacket.WriteBytes(TmpBuffer);

                            BeginReceive();

                            TmpBuffer = null;
                        }
                    }

                    if (m_TempPacket.BufferLength == m_TempPacket.Length)
                    {
                        Logger.Log("Got packet - exact length!\r\n\r\n", LogLevel.info);

                        OnPacket(new ProcessedPacket(m_TempPacket.PacketID, m_Handler.Encrypted, m_Handler.VariableLength,
                            (ushort)m_TempPacket.Length, m_ClientEncryptor, m_TempPacket.ToArray()), m_Handler);
                    }
                    else if (m_TempPacket.BufferLength < m_TempPacket.Length)
                    {
                        byte[] TmpBuffer = new byte[NumBytesRead];

                        //Store the number of bytes that were read in the temporary buffer.
                        Logger.Log("Got data, but not a full packet - stored " +
                            NumBytesRead.ToString() + "bytes!\r\n\r\n", LogLevel.info);
                        Buffer.BlockCopy(m_RecvBuf, 0, TmpBuffer, 0, NumBytesRead);
                        m_TempPacket.WriteBytes(TmpBuffer);

                        TmpBuffer = null;
                    }
                    else if (m_TempPacket.BufferLength > m_TempPacket.Length)
                    {
                        Logger.Log("Received more bytes than needed for packet. Excess: " +
                            (m_TempPacket.BufferLength - m_TempPacket.Length) + "\r\n", LogLevel.info);
                        PacketHandler OldHandler = m_Handler;

                        byte[] PacketBuffer = new byte[m_TempPacket.Length];
                        Buffer.BlockCopy(m_TempPacket.ToArray(), 0, PacketBuffer, 0, PacketBuffer.Length);

                        OnPacket(new ProcessedPacket(OldHandler.ID, OldHandler.Encrypted, OldHandler.VariableLength,
                            OldHandler.Length, m_ClientEncryptor, PacketBuffer), OldHandler);

                        byte[] TmpBuffer = new byte[m_TempPacket.BufferLength - m_TempPacket.Length];
                        Buffer.BlockCopy(m_TempPacket.ToArray(), ((int)m_TempPacket.BufferLength - (int)m_TempPacket.Length),
                            TmpBuffer, 0, TmpBuffer.Length);

                        m_TempPacket = new PacketStream(TmpBuffer[0], (ushort)(m_TempPacket.BufferLength - m_TempPacket.Length),
                            TmpBuffer);

                        m_Handler = FindPacketHandler(m_TempPacket.PacketID);
                        ushort PacketLength = m_Handler.Length;

                        if (PacketLength == 0) //Variable length!
                        {
                            if (m_TempPacket.BufferLength >= (int)PacketHeaders.ENCRYPTED)
                            {
                                PacketLength = m_TempPacket.PeekUShort(1);
                                m_TempPacket.SetLength(PacketLength);
                            }
                        }
                    }
                }

                m_Sock.BeginReceive(m_RecvBuf, 0, m_RecvBuf.Length, SocketFlags.None,
                    new AsyncCallback(ReceiveCallback), m_Sock);
            }
            catch (SocketException)
            {
                Disconnect();
            }
        }
        private void OnPacket(ProcessedPacket packet, PacketHandler handler)
        {
            if (OnReceivedData != null)
            {
                OnReceivedData(packet);
            }

            packetQueue.Enqueue(new KeyValuePair<ProcessedPacket, PacketHandler>(packet, handler));
            //handler.Handler(this, packet);
        }
        private void OnPacket(ProcessedPacket packet, PacketHandler handler)
        {
            if (OnReceivedData != null)
            {
                OnReceivedData(packet);
            }

            handler.Handler(this, packet);
        }