Add full logic to Ri(q) groups + small refactoring (Sz and Ri types
criterion)