     SET out ='';
     WHILE (bit>0) DO
 	    SET bit = bit-1;
-	    SET mask = power(cast(2 as bigint),bit);
+	    SET mask = left_shift(cast(1 as bigint),bit);
 	    CASE 
 		WHEN (bit_and(mask,value)=0) THEN SET out = out + ''; 
 		ELSE SET out = out + (coalesce((select name from SecTarget where value=mask),'')+' ');

    SET out ='';
    WHILE (bit>0) DO
	    SET bit = bit-1;
	    SET mask = power(cast(2 as bigint),bit);
	    CASE 
		WHEN (bit_and(mask,value)=0) THEN SET out = out + ''; 
		ELSE SET out = out + (coalesce((select name from FieldMask where value=mask),'')+' ');

    SET out ='';
    WHILE (bit>0) DO
	    SET bit = bit-1;
	    SET mask = left_shift(cast(1 as bigint),bit);
	    CASE 
		WHEN (bit_and(mask,value)=0) THEN SET out = out + '';
		ELSE SET out = out + (coalesce((select name from PhotoFlags where value=mask),'')+' ');
