Various updates for rails 4

Specifically for the rails4 branch.

WIP