some code refactoring, critical section for data-access, support for multiple tabs