Refactoring a bunch of tab related code

Made a bunch of changes to streamline and cleanup the code in an effort to fix various issues related to #14.
somehow, a line
Merge pull request #24 from mrkrstphr/fix014-again

Refactoring a bunch of tab related code