finished the mask linking and several smaller fixes