Fixing the initial tab highlight (the tabs and order had changed, so thi...

...s bug came bug, albeit for a different reason).

Also, some refactoring.