Major refactor to properly generate titles without repeating tons of db
queries.