Modelize. Refactored some query code.