Improve performance of getTopics() called multiple times.

Cuts down SQL queries a bit, improves performance.