Rails 4 support

Rails4 fixes, also removing deprecation warnings. All specs passing.