Added a hash length convenience function.
Added extra debug messages and used newly created length function.