Added packet validation. Now detects of server closes connection first.