Rails 4 support and small fixes