Refactor to support associations and eager loading