Fixed random deadlocks

This commit fixes the random deadlocks and internal server errors that were showing up when running Rails 3.2 on Ruby 1.9 or greater. The cookie is now getting set directly on the response headers instead of on a new Rack::Response object (which isn't thread safe). The tests are still passing 100%.