Fixed bug with output of generate_secret() not being encoded
Fixed some minor bugs related to time drift and encoding