Clean up some activerecord queries