Impurity trapping and gettering in amorphous silicon