some changes to fix some deprecations in rails 3.1+