Refactored out some redundancy in the tab conversion code