One way to fix this in the short term is to look at the range in the values and see if they exceed 180 degrees, then shift all values accordingly. This might be an issue for the mean, so it will have to be treated accordingly.