Fixed modding periodic boundaries.