Fixed Javascript errors and minor code refactor.
Removed unused table formatting library.
Wait until the page has finished loading to avoid closing all ZD tabs.