Rails4 fixes

These are the changes I'm using in my Rails4 application.  Review and comments welcome!