fixed weakness due to non cryptographic random number generator
prevented password hashes being disclosed in logs, rewrote some functions to use private queries