improvment & refactoring, bugfix for last used tabs