Some cleanup at ActiveRecord class  and code reutilization