Move WMI queries out of global scope