querywindow: change manual memory management to automatic
Fix collate clause trailing spaces
Simplify query storage in querywindow a bit. Use http://wiki.lazarus.freepascal.org/DebugServer instead of LazLogger for logging as it's probably more suited for multithreaded applications