Refactor homepage/errorlog queries