fixed some cases where equal values have been computed multiple times;
fixed masking and branching for the Sierra-if