Reoriented all the code towards a better ActiveRecord integration