Fix pivoting

I found the error from #1. There might more, but that is for tomorrow.