Fixes for Rails 4 compatibility

Also cleaned up some trailing whitespace in the files I was modifying.