Updated 1d and 3d code