Fixes for rails 4.1

And some other small fixes.