The debug flag is set in the TEB (Thread environment block). The easiest and I think best way to evade being detected is performing the following code
CODE
00D6CA8F > 64:A1 18000000 MOV EAX,DWORD PTR FS:[18]
00D6CA95 8B40 30 MOV EAX,DWORD PTR DS:[EAX+30]
00D6CA98 C640 02 00 MOV BYTE PTR DS:[EAX+2],0
with that set , kernel32.IsDebuggerPresent will return 0, and any userland self checks will fail.