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.

Fixes #14