Minor cleanup, using AR querying DSL over raw SQL in some places