minor cleanup, using AR querying DSL over raw SQL in some places
Merge pull request #300 from goshakkk/cleanup

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