Bug fixes

Fixed some bugs I introduced when permuting and calculating p-values.