Fix null handling in the rank function
Add sha1 and minor code cleanup