Fixed bug in reading secrets from file.  Cleaned up the code a bit along the way.