Critical fixes for ActiveRecord issues