Added support for second tab. Many bug fixes.