avoid usage of global variables

In addition, patchType and fileType are never used