Fix and reenable rank optimizer

Fixes #68.