Fixed a tab bug and implemented saving active tab