Minor changes. Note that 2d case should be implemented.