Fixes to activerecord