Bugfixes and Rails 4.0.1 upgrade