Refactor keywords.rake & group_history.rake to use the relations instead of querying all these stuff again.