improved rails 4 compatibility