diff --git a/bin/alexandria b/bin/alexandria
index ea844a6..de81e4a 100644
--- a/bin/alexandria
+++ b/bin/alexandria
@@ -1,6 +1,6 @@
-#!/usr/bin/env ruby
+#!/usr/bin/ruby -Ku
 
-$KCODE = 'U'
+ENV['LC_ALL'] = 'C'
 
 begin
   require 'gettext'
diff --git a/lib/alexandria/book_providers/amazon_ecs_util.rb b/lib/alexandria/book_providers/amazon_ecs_util.rb
index 3c01d57..3e5b030 100644
--- a/lib/alexandria/book_providers/amazon_ecs_util.rb
+++ b/lib/alexandria/book_providers/amazon_ecs_util.rb
@@ -32,9 +32,7 @@ require 'net/http'
 require 'hpricot'
 require 'cgi'
 
-require 'digest/sha2'
-require 'base64'
-
+require 'openid'
 
 module Amazon
   class RequestError < StandardError; end
@@ -229,35 +227,6 @@ module Amazon
         s.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
       end
 
-
-
-    def self.hmac_sha256(message, key)
-      block_size = 64 
-      ipad = "\x36" * block_size
-      opad = "\x5c" * block_size
-      if key.size > block_size
-        d = Digest::SHA256.new
-        key = d.digest(key)
-      end
-      
-      for i in 0 .. key.size - 1
-        ipad[i] ^= key[i]
-        opad[i] ^= key[i]
-      end
-      
-      # inner hash
-      d1 = Digest::SHA256.new
-      d1.update(ipad)
-      d1.update(message)
-      msg_hash = d1.digest()
-      
-      # outer hash
-      d2 = Digest::SHA256.new
-      d2.update(opad)
-      d2.update(msg_hash)
-      d2.digest
-    end
-
     def self.sign_request(request)
       raise AmazonNotConfiguredError unless @@secret_access_key
       # Step 0 : Split apart request string
@@ -291,8 +260,8 @@ module Amazon
       #puts string_to_sign
 
       # Step 8 : Calculate RFC 2104-compliant HMAC with SHA256 hash algorithm
-      sig = hmac_sha256(string_to_sign, @@secret_access_key)     
-      base64_sig = Base64.encode64(sig).strip
+      sig = OpenID::CryptUtil::hmac_sha256(@@secret_access_key, string_to_sign)     
+      base64_sig = OpenID::Util::to_base64(sig).strip
       
       # Step 9 : URL-encode + and = in sig
       base64_sig = CGI.escape(base64_sig)
diff --git a/lib/alexandria/net.rb b/lib/alexandria/net.rb
index eda4c6a..c7a253b 100644
--- a/lib/alexandria/net.rb
+++ b/lib/alexandria/net.rb
@@ -6,7 +6,7 @@ module Alexandria
   class WWWAgent
     def initialize()
       user_agent = "Ruby #{RUBY_VERSION} #{Alexandria::TITLE}/#{Alexandria::VERSION}"
-      @extra_request_headers = {"User-Agent", user_agent}
+      @extra_request_headers = {"User-Agent" => user_agent}
     end
 
     def self.transport
@@ -31,7 +31,7 @@ module Alexandria
     end
 
     def user_agent=(agent_string)      
-      @extra_request_headers = {"User-Agent", agent_string}
+      @extra_request_headers = {"User-Agent" => agent_string}
     end
   end
   
