Cleanup, and added transpose for non-square grids