Clean up code of parser
Fix condition to abort rank calculation