Sergey's 6.3. Basis count bug fixing