Slight refactor of constructTabs
Bug fixes to preserve old behaviour