Adjusting weights, fixing start pixel of transitional and adding sqrt stuff to variance