Bug fixing and refactoring of the sqlite hash lookup functionality.