Role of substrate and transparent conducting oxide in impurity evolvement in polycrystalline thin-film devices