More substantial fixes to run with N>2.