Corrected token hashing and fixed other minor bugs.