Bugfixes in STUB rank calculation