Added table of contents and fix some bugs