Bug fixes for 3D periodic