add working opening architecture: horrible code though...
fix opening tab behavior
minor refactoring