Fixed some bugs and details. Also added gather pcorr function.