The original code here could result in undefined behaviour because the type might not match preferred tech mask. Please either fix it in this patch or file a new bug instead.