Move the tab creation into function.

This somehow lets the tabs to appear in any order. This didn't really work
before (the compare tab would overwrite everything that came after it).

Credit: Max Whitney