Fix for incompatibility with Rails 3.2.x. Fix for STI classes. Simpler code