Factored out some common code into a function to determine which table view was visible (normal or search results).
Added some doc comments.