Various fixes for 4.1.x support

Some fixes for the 4.1.x branch - with these applied all the tests in https://github.com/openstreetmap/openstreetmap-website are passing with rails 4.1.1 without problems.