improve some popular queries and add file logging