Rails4 integration progress

Various issues identified and resolved.

This Rails4 version is not yet ready for release -- please see the README for details.