Delete some duplicate code in singleton, some clean in getNodeListFromDoc and fix errors