Move common functions to globals
Remove qhash