Fix some incompatibilities with Rails 4.