Fix rank function. Closes #34.
Merge pull request #39 from nbeloglazov/master

Fix rank function.