refactor to make OpenFile/OpenDebFile more robust
ensure clean works
refactor _InitQuery()