Thread sync and memory free fixups in RDP plugin