More tweaks to connection.rb and authenticate.rb